import 'package:flutter/material.dart';

// 导入屏幕页面
import 'screens/home/home_screen.dart';
import 'screens/video/video_screen.dart';
import 'screens/adoption/adoption_screen.dart';
import 'screens/community/community_screen.dart';
import 'screens/profile/profile_screen.dart';
import 'screens/splash_screen.dart';
import 'screens/login_screen.dart';
import 'screens/main_screen.dart';
import 'screens/adoption/pet_detail_screen.dart';
import 'screens/community/post_detail_screen.dart';
import 'screens/videos/video_detail_screen.dart';
import 'screens/profile/settings_screen.dart';
import 'screens/profile/favorite_pets_screen.dart';
import 'screens/profile/favorite_posts_screen.dart';
import 'screens/profile/favorite_videos_screen.dart';
import 'screens/profile/history_screen.dart';
import 'screens/profile/follow_list_screen.dart';
import 'screens/notification/notification_screen.dart';
import 'screens/search/search_screen.dart';

// 定义路由名称常量
class Routes {
  static const String home = '/';
  static const String video = '/video';
  static const String adoption = '/adoption';
  static const String community = '/community';
  static const String profile = '/profile';
  
  // 其他详情页面
  static const String videoDetail = '/video/detail';
  static const String petDetail = '/adoption/detail';
  static const String postDetail = '/community/detail';
}

class AppRoutes {
  static const String splash = '/';
  static const String login = '/login';
  static const String main = '/main';
  static const String petDetail = '/pet/detail';
  static const String postDetail = '/post/detail';
  static const String videoDetail = '/video/detail';
  static const String settings = '/profile/settings';
  static const String favoritePets = '/profile/favorite/pets';
  static const String favoritePosts = '/profile/favorite/posts';
  static const String favoriteVideos = '/profile/favorite/videos';
  static const String history = '/profile/history';
  static const String followers = '/profile/followers';
  static const String following = '/profile/following';
  static const String notifications = '/notifications';
  static const String search = '/search';

  static Map<String, WidgetBuilder> getRoutes() {
    return {
      splash: (context) => SplashScreen(),
      login: (context) => LoginScreen(),
      main: (context) => MainScreen(),
      settings: (context) => SettingsScreen(),
      favoritePets: (context) => FavoritePetsScreen(),
      favoritePosts: (context) => FavoritePostsScreen(),
      favoriteVideos: (context) => FavoriteVideosScreen(),
      history: (context) => HistoryScreen(),
      notifications: (context) => NotificationScreen(),
      search: (context) => SearchScreen(),
    };
  }

  // 需要传递参数的路由使用这个方法生成
  static Route<dynamic> generateRoute(RouteSettings settings) {
    switch (settings.name) {
      case petDetail:
        final pet = settings.arguments as dynamic;
        return MaterialPageRoute(
          builder: (_) => PetDetailScreen(pet: pet),
        );
      case postDetail:
        final post = settings.arguments as dynamic;
        return MaterialPageRoute(
          builder: (_) => PostDetailScreen(post: post),
        );
      case videoDetail:
        final video = settings.arguments as dynamic;
        return MaterialPageRoute(
          builder: (_) => VideoDetailScreen(video: video),
        );
      case followers:
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(
          builder: (_) => FollowListScreen(
            userId: args['userId'],
            username: args['username'],
            type: FollowListType.followers,
          ),
        );
      case following:
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(
          builder: (_) => FollowListScreen(
            userId: args['userId'],
            username: args['username'],
            type: FollowListType.following,
          ),
        );
      default:
        return MaterialPageRoute(
          builder: (_) => Scaffold(
            body: Center(
              child: Text('找不到路由: ${settings.name}'),
            ),
          ),
        );
    }
  }
} 